import Config from "./components/Config.js";
import lodash from "lodash";
import path from "path";
import { pluginRoot } from "./model/path.js";

export function supportGuoba() {
  return {
    pluginInfo: {
      name: '橙子mc插件',
      title: '橙子mc插件',
      author: ['@Kevin', '@xiaofeiawa','@smallcui'],
      authorLink: ['https://gitee.com/Kevin1217'],
      link: 'https://gitee.com/Kevin1217/xiaocheng_Minecraft',
      isV3: true,
      isV2: false,
      description: '基于Yunzai-Bot的Minecraft插件，简化了Minecraft的交互，无需打开控制台来访问Minecraft',
      // 显示图标，此为个性化配置
      // 图标可在 https://icon-sets.iconify.design 这里进行搜索
      icon: 'mdi:minecraft',
      // 图标颜色，例：#FF0000 或 rgb(255, 0, 0)
      //iconColor: '#d19f56',
      // 如果想要显示成图片，也可以填写图标路径（绝对路径）
      //iconPath: path.join(pluginRoot, 'resources/readme/girl.png'),
    },
    configInfo: {
      schemas: [
        {
          component: "Divider",
          label: "ServerTap 相关配置",
          componentProps: {
            orientation: "left",
            plain: true,
          },
        },
        {
          field: "ip",
          label: "服务器IP或域名",
          component: "Input",
        },
        {
          field: "port",
          label: "ServerTap端口",
          bottomHelpMessage: "注意不是游戏端口！",
          component: "Input",
        },
      ],
      getConfigData() {
        let config = Config.getConfig()
        return config
      },

      setConfigData(data, { Result }) {
        let config = {}
        for (let [keyPath, value] of Object.entries(data)) {
          lodash.set(config, keyPath, value)
        }
        config = lodash.merge({}, Config.getConfig(), config)
        Config.setConfig(config)
        return Result.ok({}, '保存成功~')
      },
    },
  }
}